﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using VOL.Entity.DomainModels;

namespace VOL.demo.IServices.wms.ShopOrder
{
    public interface IShopOrderService
    {
        /// <summary>
        /// 分页查询销售订单
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页记录数</param>
        /// <param name="whereExpression">查询条件</param>
        /// <returns>分页结果</returns>
        Task<(List<shopordermodel> Data, int TotalCount)> GetPageListAsync(int pageIndex, int pageSize,
            Expression<Func<shopordermodel, bool>> whereExpression = null);

        /// <summary>
        /// 分页查询销售订单联查结果（包含客户名称、部门名称、用户名称）
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页记录数</param>
        /// <param name="shopOrderCode">销售单号（可选）</param>
        /// <param name="shopOrderDate">销售日期（可选）</param>
        /// <returns>分页结果</returns>
        Task<(List<ShopOrderDto> Data, int TotalCount)> GetPageListWithRelationsAsync(
            int pageIndex,
            int pageSize,
            string shopOrderCode = null,
            DateTime? shopOrderDate = null);

        /// <summary>
        /// 根据ID获取销售订单
        /// </summary>
        /// <param name="id">销售订单ID</param>
        /// <returns>销售订单信息</returns>
        Task<shopordermodel> GetByIdAsync(long id);

        /// <summary>
        /// 更新销售订单
        /// </summary>
        /// <param name="entity">销售订单实体</param>
        /// <returns>更新结果</returns>
        Task<bool> UpdateAsync(shopordermodel entity);

        /// <summary>
        /// 删除销售订单
        /// </summary>
        /// <param name="id">销售订单ID</param>
        /// <returns>删除结果</returns>
        Task<bool> DeleteAsync(long id);

        /// <summary>
        /// 批量删除销售订单
        /// </summary>
        /// <param name="ids">销售订单ID列表</param>
        /// <returns>删除结果</returns>
        Task<bool> DeleteRangeAsync(long[] ids);

        /// <summary>
        /// 获取货品分页列表
        /// </summary>
        /// <param name="searchDto">查询参数</param>
        /// <returns>货品分页结果</returns>
        Task<(List<ProductDisplayDto> Data, int TotalCount)> GetProductPageListAsync(ProductSearchDto searchDto);

        /// <summary>
        /// 获取部门级联列表
        /// </summary>
        /// <param name="searchDto">查询参数</param>
        /// <returns>部门级联结果</returns>
        Task<List<DepartmentCascadeDto>> GetDepartmentCascadeListAsync(DepartmentSearchDto searchDto);

        /// <summary>
        /// 获取用户下拉选择列表
        /// </summary>
        /// <param name="searchDto">查询参数</param>
        /// <returns>用户下拉选择结果</returns>
        Task<(List<UserSelectDto> Data, int TotalCount)> GetUserSelectListAsync(UserSearchDto searchDto);

        /// <summary>
        /// 添加销售订单和销售订单明细（使用事务）
        /// </summary>
        /// <param name="createDto">销售订单和销售订单明细创建DTO</param>
        /// <returns>添加结果</returns>
        Task<bool> AddWithDetailsAsync(ShopOrderWithDetailsCreateDto createDto);

        /// <summary>
        /// 获取所有客户简单列表（仅ID和名称）
        /// </summary>
        /// <returns>客户简单列表</returns>
        Task<List<CustomerSimpleDto>> GetAllCustomersSimpleAsync();
    }
}
